home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F23298_DocumentWithNodesetXML.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.8 KB  |  41 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       MultipleDataSources
  4.   Sub-category:   XML
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylsheet demonstrates how to combine multiple XML
  10.     documents into a single data source.  In this example, the
  11.     document names are stored as an attribute value.  The
  12.     stylesheet that combines the data first accesses each XML
  13.     Document name using the document() function (demonstrating
  14.     also how an xPath query can be applied to the document) and
  15.     displays each document as HTML using the DisplayProds
  16.     template.
  17.     Note: This example was originally inspired by Kurt Cagle
  18.     (http://www.KurtCagle.net).
  19. ================================================================ -->
  20. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  21.   <xsl:output method="xml" />
  22.  
  23.   <xsl:template match="/">
  24.     <!--Create a variable which holds the names of the xml documents we are combining -->
  25.     <xsl:variable name="doc.refs.1">
  26.       <xsl:for-each select="ProductFiles/file">
  27.         <doc>
  28.           <xsl:value-of select="@href" />
  29.         </doc>
  30.       </xsl:for-each>
  31.     </xsl:variable>
  32.  
  33.     <!-- Iterate through the variable and display access xml document using the document() object.  Note: We are using the MSXML implementation of the node-set function to access the contents as a nodeset. -->
  34.     <document>
  35.       <xsl:for-each select="msxsl:node-set($doc.refs.1)//doc">
  36.         <xsl:copy-of select="document(.)" />
  37.       </xsl:for-each>
  38.     </document>
  39.   </xsl:template>
  40. </xsl:stylesheet>
  41.